<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增项目设计工作联系函')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <style>
		.file-preview {
		    padding: 0;
		    margin-bottom: 0;
		    border-radius: 0;
		    border: none;
		}
		
		.krajee-default.file-preview-frame {
		    margin-right: 20px;
		    padding: 0;
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default.file-preview-frame:not(.file-preview-error):hover {
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default .file-footer-caption {
			margin-bottom: 0;
		}
		
		.krajee-default.file-preview-frame .file-thumbnail-footer {
		    height: auto;
		}
		
		.krajee-default .file-caption-info {
			width: auto;
		}
		
		.kv-upload-progress .progress {
			margin-top: 0;
		}
		
		.krajee-default.file-preview-frame .kv-file-content,
		.krajee-default .file-size-info,
		.krajee-default .file-upload-indicator,
		.file-input .kv-file-upload,
		.file-input .kv-file-zoom {
			display: none;
		}
		
		.file-input .kv-file-remove {
			position: absolute;
			top: 3px;
			right: -15px;
			height: 14px;
			padding: 0;
			margin: 0;
			border: none;
			background: none;
		}
		
		.file-input .kv-file-remove:active, 
		.file-input .kv-file-remove:focus {
			background: none;
			outline: none;
			box-shadow: none;
		}
		
		.file-input .kv-file-remove .glyphicon-trash {
			color: red;
		}
	</style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-fun-add">
        	<input name="gcProjectid" id="gcProjectid" type="hidden" th:value="${gcProject.id}" >
        	<input name="ownerId" class="form-control" type="hidden" th:value="${ownerId}">
            <input name="deptId" class="form-control" type="hidden" th:value="${deptId}">
            <input id="hfunfile" name="hfunfile" type="hidden">
            <input type="hidden" id="approvename" name="approvename" th:value="${approvename}" />
            <input type="hidden" id="type" name="type" value="0" /><!-- 发函1 来函0 -->
            <h4 class="form-header h4">收函信息</h4>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">项目名称：</label>
                <div class="col-sm-4">
                    <input name="projectName" class="form-control" type="text" required th:value="${gcProject.name}" readonly="readonly">
                </div>
                <label class="col-sm-2 control-label is-required">建设单位：</label>
                <div class="col-sm-4">
                    <input name="clientName" class="form-control" type="text" required th:value="${gcProject.customerName}" readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">申请人：</label>
                <div class="col-sm-4">
                    <input name="owner" class="form-control" th:value="${owner}" type="text" required readonly="readonly">
                </div>
                <label class="col-sm-2 control-label is-required">申请部门：</label>
                <div class="col-sm-4">
                    <input name="dept" class="form-control" th:value="${deptName}" type="text" required readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label ">收函编号：</label>
                <div class="col-sm-4">
                    <input name="hfunNo" class="form-control" type="text" >
                </div>
                <label class="col-sm-2 control-label ">收函名称：</label>
                <div class="col-sm-4">
                    <input name="hfunName" class="form-control" type="text" >
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label ">收函时间：</label>
                <div class="col-sm-4">
                    <div class="input-group date">
                        <input name="hfunAt" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
                <label class="col-sm-2 control-label ">等级：</label>
                <div class="col-sm-4">
                    <select id="level" name="level" class="form-control" >
						<option value="紧急">紧急</option>
						<option value="普通">普通</option>
					</select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label ">收函内容：</label>
                <div class="col-sm-10">
                    <textarea name="hfunDescs" class="form-control" ></textarea>
                </div>
            </div>
            <div class="form-group">
	            <label class="col-sm-2 control-label">收函文件：</label>
	            <div class="col-sm-10">
	            	<div class="file-loading">
		            	<input id="multipleFile" name="files" type="file" multiple>
		        	</div>
	            </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <th:block th:include="include :: bootstrap-typeahead-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script th:inline="javascript">
        var prefix = ctx + "sj/fun"
        $("#form-fun-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/add4lai", $('#form-fun-add').serialize());
            }
        }

        $("input[name='sendAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        
        $("input[name='hfunAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(document).ready(function () {
		       // 多图上传
		       $("#multipleFile").fileinput({
		           uploadUrl: "/common/uploads",
		           uploadAsync: false,
		           showClose: false,
		           showCancel: false,
		           dropZoneEnabled: false,
		           buttonLabelClass: ''
		       }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
		       	var rsp = data.response;
//		       	   log.info("return urls：" + rsp.urls)
		           log.info("reutrn fileNames：" + rsp.fileNames)
//		           log.info("reutrn newFileNames：" + rsp.newFileNames)
//		           log.info("return originalFilenames：" + rsp.originalFilenames)
				   $("#hfunfile").val(rsp.fileNames);
		       }).on('fileremoved', function (event, id, index) {
		           $("input[name='" + event.currentTarget.id + "']").val('')
		       })
		 });
        
      //选择用户level1
		function selectlevel1() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel1User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel1User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#fzrId").val(rows[0].userId);
            $("#fzr").val(rows[0].userName);
            $("#fzrStr").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level1
		function selectlevel2() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel2User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel2User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#sprId").val(rows[0].userId);
            $("#spr").val(rows[0].userName);
            $("#sprStr").val(rows[0].userName);
            $.modal.closeAll();
        }
    </script>
</body>
</html>